#include "Mygtukas.h"

void Mygtukas::draw(HDC hdc)
{
	Bitmap bmp(width,height);

	Graphics *fromImg = Graphics::FromImage(&bmp); //

	Pen			penBorder(Color(255, 0, 0, 0));

	// nupiesiamas fonas
	//fromImg->FillRectangle(&brushBackground, 1, 1, width-2, height-2);
	// remelis
	fromImg->DrawRectangle(&penBorder, 0, 0, width-1, height-1);

	fromImg->DrawImage(buttonBg, 0, 0, width, height);
	
	Graphics    graphics(hdc);
	graphics.DrawImage(&bmp, x, y, width, height);

	delete fromImg;
}


void Mygtukas::click()
{
	LPPOINT p = new POINT;
	GetCursorPos(p);
	ScreenToClient(hWnd, p);


	if(p->x >= x+1 && p->x <= x + width-1 &&
		p->y >= y && p->y <= y + height)
	{
		SendMessage(hWnd, WM_COMMAND, control_id, 0);
	}

	delete[] p;
}